﻿using Compass.Wasm.Shared.Wms;

namespace Compass.Maui.Services.Cargoes;
public interface IInventoryService:IBaseService<InventoryDto>
{
    Task<List<InventoryDto>> GetMauiAllByPeriodAsync(DateTime start, DateTime end, string? search = null);
}
public class InventoryService:BaseService<InventoryDto>,IInventoryService
{
    private readonly IHttpRestClient _client;
    private const string ServiceName = "Inventory";

    public InventoryService(IHttpRestClient client) : base(client, ServiceName)
    {
        _client = client;
    }

    public async Task<List<InventoryDto>> GetMauiAllByPeriodAsync(DateTime start, DateTime end,string? search = null)
    {
        var strSearch = string.IsNullOrEmpty(search) ? "" : $"&search={search}";
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"{ServiceName}/Maui/Period?start={start}&end={end}{strSearch}"
        };
        var response= await _client.ExecuteAsync<List<InventoryDto>>(request);
        return response.Status ? response.Result : new List<InventoryDto>();
    }
}